package com.sleep.blog.controller;

import com.sleep.blog.service.CategoryService;
import com.sleep.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Sleep-6000
 * @date 2021/10/3
 */
@RestController
@RequestMapping("categorys")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 查询所有分类
     * @return 查询结果
     */
    @GetMapping
    public Result findAll(){
        return categoryService.findAll();
    }

    /**
     * 查询所有分类详情
     * @return 查询结果
     */
    @GetMapping("detail")
    public Result categoriesDetail(){
        return categoryService.findAllDetail();
    }

    /**
     * 根据 id 查询分类详情
     * @param id id
     * @return 查询结果
     */
    @GetMapping("detail/{id}")
    public Result categoryDetailById(@PathVariable("id") Long id){
        return categoryService.categoryDetailById(id);
    }
}
